Importing weights and biases

(* model.txt file in the notebook directory is required! *)
SetDirectory@NotebookDirectory[];
{u,v,U,V}=ToExpression/@StringSplit[Import["model.txt"],"\n"];
Dimensions/@{u,v,U,V} (* dimensions of the bias vectors and weight matrices *)

Neural Network

σ[x_]:=(1./(1+Exp[-x])); (* activation function *)

(* Forward Pass function*)
ForwPass[x_]:=Module[{p,q,y},
p=V.x+v;
y=σ[p];
q=U.y+u;
σ[q] (* =z (one-hot encoding of a digit) *)
];

Testing set

samples={,,,,,,,,,};
in=Flatten/@ImageData/@samples; (* converting the testing images into input vectors *)

Forward pass example

x=in[[7]]; (* input vector selection *)
z=ForwPass[x]; (* output vector (encoding of the digit) *)
ListLinePlot[z,PlotRange->Full,InterpolationOrder->2](* graphic representation of the one-hot encoding *)

Optical character recognition

(* recognition function *)
OCR[img_]:=Module[{x,out},
x=Flatten@ImageData@ColorConvert[img,"Grayscale"]; (* converting input images into vectors *)
out=ForwPass[x]; (* Neural Network Forward Pass *)
First@Ordering[out,-1]-1 (* converting output one-hot vectors into corresponding numbers *)
];

OCR test

(* place your own 28\[Cross]28 px images of digits for testing *)

OCR[]